package com.xiaotu.service.sw.impl;

import com.xiaotu.dao.sw.SwMapper;
import com.xiaotu.service.sw.SwService;
import com.xiaotu.vo.*;
import jdk.nashorn.internal.ir.IfNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author zhangxiao
 * @create 2021-08-26 14:14
 */
@Service
public class SwServiceImpl implements SwService {

    @Autowired
    private SwMapper swMapper;

    @Override
    public Boolean getSwIsAuthSuccess(Integer starId) {
        return swMapper.getSwIsAuthSuccess(starId);
    }

    @Override
    public SwInfoVo getSwInfoByStarId(Integer starId) {
        return swMapper.getSwInfoByStarId(starId);
    }

    @Override
    public List<ActorAwardVo> getActorAwards(Integer starId) {
        return swMapper.getActorAwards(starId);
    }

    @Override
    public List<PartiWorksVo> getPartiWorks(Integer starId, Integer showType) {
        List<PartiWorksVo> works = swMapper.getPartiWorks(starId);
        if (showType == 1) {
            works.stream().forEach(w -> {
                if (w.getWorkList().size() >= 4)
                    w.setWorkList(w.getWorkList().subList(0, 4));
            });
            return works;
        } else if (showType == 2) {
            return works;
        }
        return null;
    }

    @Override
    public List<PartiWorksInfoVo> getPartiWorksInfo(Integer starId, Integer tvType) {
        return swMapper.getPartiWorksInfo(starId, tvType);
    }

    @Override
    public List<CoActorVo> getCoActors(Integer starId) {
        return swMapper.getCoActors(starId);
    }

    @Override
    public List<CoActorInfoVo> getCoActorInfos(Integer occu, Integer starId) {
        return swMapper.getCoActorInfos(occu, starId);
    }

    @Override
    public Map<String, Object> getFansCommentsCount(Integer starId) {
        return swMapper.getFansCommentsCount(starId);
    }

    @Override
    public Integer getAuthType(Integer starId) {
        return swMapper.getAuthType(starId);
    }

}
